package com.mingxi.backend.controller;

import com.github.pagehelper.PageInfo;
import com.mingxi.backend.common.Result;
import com.mingxi.backend.pojo.entity.StuCourse;
import com.mingxi.backend.service.StuCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/course/stu")
public class StuCourseController {

    @Autowired
    private StuCourseService stuCourseService;

//    @GetMapping("/{stuId}")
//    public Result getMyCourses(@PathVariable int stuId, @RequestParam int pageSize,@RequestParam int page){
//        PageInfo<StuCourse> stuCoursePageInfo = stuCourseService.getMyCourse(stuId, pageSize, page);
//        return Result.success(stuCoursePageInfo);
//    }

    @GetMapping("/{stuId}")
    public Result getCourse(@PathVariable int stuId, @RequestParam int pageSize,@RequestParam int pageNumber) {
        PageInfo<StuCourse> myCourse = stuCourseService.getMyCourse(stuId, pageSize, pageNumber);
        return Result.success(myCourse);
    }

    @DeleteMapping()
    public Result deleteCourse(@RequestParam int stuId, @RequestParam int stuCourseId) {
        stuCourseService.deleteCourse(stuId, stuCourseId);
        return Result.success("退课成功！");
    }
}
